<template>
  <div><!--借款人-用户-->

    <el-row>
      <el-col :span="24" :offset="0" style="margin-top:30px;">

        <el-row :gutter="0" style="border: 1px solid white">
          <!--<el-col :span="7" :offset="0" style="">
            <el-input placeholder="请输入借款人" v-model="searchValue" class="">
              <el-button slot="append" icon="el-icon-search" @click="querySubmit"></el-button>
            </el-input>
          </el-col>-->

          <el-col :span="2" :offset="11" style="">
            <el-button type="success" style="float: right" @click="addBorrower">新增</el-button>
          </el-col>
        </el-row>


        <el-row :gutter="0" style="margin-top:20px;border: 1px solid white">
          <el-col :span="24" :offset="0" >
            <el-table stripe :data="tableData1" :header-cell-style="{lineHeight:'20px'}" style="width: 100%"><!--height="840"-->
              <el-table-column fixed prop="id" label="用户编号"></el-table-column>
              <el-table-column prop="username" label="用户名"></el-table-column>
              <el-table-column prop="password" label="密码"></el-table-column>
              <el-table-column prop="name" label="姓名"></el-table-column>
              <el-table-column prop="sex" label="性别"></el-table-column>
              <el-table-column prop="address" label="家庭地址"></el-table-column>
              <el-table-column prop="phone" label="手机号"></el-table-column>
              <el-table-column prop="identitycard" label="身份证"></el-table-column>
              <el-table-column prop="email" label="邮箱"></el-table-column>
              <el-table-column prop="role" label="角色"></el-table-column>
              <el-table-column prop="banknameLoan" label="借款开户行名称"></el-table-column>
              <el-table-column prop="bankcardnoLoan" label="借款银行卡号"></el-table-column>
              <el-table-column prop="limitnum" label="信用额度"></el-table-column>
              <el-table-column prop="banknameRepayment" label="还款开户行名称"></el-table-column>
              <el-table-column prop="bankcardnoRepayment" label="还款银行卡号"></el-table-column>
              <el-table-column fixed="right" label="操作" width="150">
                <template slot-scope="scope">
                  <el-button type="success" icon="el-icon-edit" @click="updateCart(scope.row.id)" circle></el-button>
                  <el-button type="danger" icon="el-icon-delete" @click.native.prevent="deleteCart(scope.row.id)" circle></el-button>
                </template>
              </el-table-column>
            </el-table>

          </el-col>
        </el-row>

      </el-col>
    </el-row>

  </div>
</template>

<script>

  import axios from 'axios';
  export default {
    name: "borrower",
    data() {
      return {
        tableData1: [],
        searchValue: ''
      }
    },
    methods: {
      handleClick(row) {
        console.log(row);
      },
      querySubmit() {
        console.log('submit!');
      },

      findAll:function () {
        axios.get("http://localhost:9999/credit-borrower/findAll").then(res=>{
          /*alert(res.data)*/
          console.log(res.data)
          this.tableData1=res.data
        })
      },
      addBorrower:function () {
        this.$router.push("/borrowerInsert")
      },
      updateCart:function (id) {
        this.$router.push({name:"borrowerInsert",params:{id:id}})
      },
      deleteCart:function (id) {
        axios.post("http://localhost:9999/credit-borrower/deleteById",{id:id}).then(res=>{
          this.findAll();
        })
      }
    },
    mounted(){
      this.findAll();
    }
  }
</script>

<style scoped>

</style>
